import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const Home = resolve => require(['../page/Home'], resolve)
const ProductList = resolve => require(['../page/ProductList'], resolve)
const ProductView = resolve => require(['../page/ProductView'], resolve)
const CheckoutCart = resolve => require(['../page/Cart/Cart'], resolve)
const FireCheckout = resolve => require(['../page/Cart/FireCheckout'], resolve)
const Customer = resolve => require(['../page/Customer'], resolve)
const Register = resolve => require(['../page/Customer/Register'], resolve)
const Login = resolve => require(['../page/Customer/Login'], resolve)

const routes = [{
    path: '/',
    component: Home
}, {
    path: '/home',
    component: Home
}, {
    path: '/list/:CateName',
    component: ProductList,
    media: { scrollTop: true }
}, {
    path: '/product/view/:productName',
    component: ProductView
}, {
    path: '/cart',
    component: CheckoutCart
}, {
    path: '/firecheckout',
    component: FireCheckout
}, {
    path: '/customer',
    component: Customer,
    children: [{
        path: '',
        component: Login,
    }, {
        path: 'register',
        component: Register,
    }, {
        path: 'login',
        component: Login,
    }]
}, {
    path: '*',
    redirect: '/'
}]
export default new Router({
    mode: 'history',
    base: __dirname,
    scrollBehavior: () => ({ y: 0 }),
    routes
})